package com.app.micaihu.bean;

import android.text.TextUtils;

import com.app.micaihu.app.AppApplication;
import com.app.micaihu.configure.AppConfigTools;
import com.app.utils.util.AppTools;

/**
 * 程序安装判断类(有关APP的类可以继承)
 * Created by linkai on 2017/3/14.
 */
public class InstallBean {

    protected String packageName;//程序包名
    protected String isInstall;//程序是否安装

    public String getPackageName() {
        return packageName;
    }

    public void setPackageName(String packageName) {
        this.packageName = packageName;
    }

    public InstallBean(){}

    public InstallBean(String packageName){
        this.packageName = packageName;
    }


    /**
     * 获取下载的游戏是否安装
     * @return
     */
    public boolean isinstall(){
        if(AppConfigTools.installValue != 0){
            //如果有应用安装或卸载 则每次都去获取是否安装
            return AppTools.isAppInstall(AppApplication.getInstance(), packageName);
        }
        if(TextUtils.isEmpty(isInstall)){
            //如果等于空 说明没有判断过，那么进行判断
            boolean b = AppTools.isAppInstall(AppApplication.getInstance(),packageName);
            if(b){
                isInstall = "0";
            }else{
                isInstall = "1";
            }
        }
        return TextUtils.equals(isInstall,"0");

    }
}
